﻿{include file="/public/header" /}
<div class="content-wraper full">
    <div class="tools-bar">
        <a data-key="info"><i class="fa fa-fw fa-info-circle"></i> 订单房态</a>
        <a data-key="migrate"><i class="fa fa-link"></i> 订单并房</a>
        <a data-key="checkout"><i class="fa fa-check-circle"></i> 订单结账</a>
    </div>
    <div class="normal-line"></div>
    <div class="search_wraper" style="min-height: 51px;">
        <form class="normal_form search_form" onsubmit="return false;">
            <div class="condition" onscroll="Core.scrolling(this)">
                <div class="row inline-row" row-name="mydatetime">
                    <div class="field_text">订单日期：</div>
                    <div style="display: inline-block;vertical-align: top;">
                        <input type="text" name="dateline[0]" id="dateline0" data-options="seconds:false,maxDate:dateline1" class="input-text date-ico" isHideClear isHidereadOnly readonly value="{$Today ?? ''}" defaultv="{$Today ?? ''}" placeholder="请选择开始时间" />
                        <span class="form-to">-</span> <input type="text" name="dateline[1]" id="dateline1" data-options="seconds:false,minDate:dateline0" class="input-text date-ico" isHideClear isHidereadOnly readonly value="{$Today ?? ''}" defaultv="{$Today ?? ''}" placeholder="请选择结束时间" />
                    </div>
                </div>
            </div>
            <div class="row form-footer-bar">
                <button class="btn" type="reset" role="btn-cancel">重置</button>
                <button r-button class="btn btn-primary search-btn" type="submit" role="btn-submit">搜索</button>
                <button r-button style="display: none;" class="btn switch_search filter">展开搜索条件<i class="fa fa-angle-down"></i></button>
                <div style="margin: 10px 0 -10px;"><a class="search_close"><i class="fa fa-angle-up"></i>收起</a></div>
            </div>
        </form>
    </div>
    <div class="table_box">
        <table class="table_main" id="datalist"></table>
    </div>
</div>
<script type="text/javascript">
Core.Easyui.FieldColumn = [
	{field:'loge',title:'包厢ID',width:100,align:'center'},
    {field:'salname',title:"包厢销售",width:100,align:'center'},
    {field:'amount',title:"包厢钟费",width:100,align:'center'},
    {field:'payment',title:"订单状态",width:100,align:'center',formatter:function(value,row,index){
        return ['<span style="color:red">使用中</span>','<span style="color:green">已结账</span>'][value] || '';
	}},
    {field:'kday',title:"订单日期",width:130,align:'center'},
    {field:'dateline',title:"开房时间",width:130,align:'center'},
    {field:'pend',title:"结束时间",width:130,align:'center'},
    {field:'preset',title:"预定时间",width:130,align:'center'},
];
Core.Easyui.FrozenColumn = [
    {field:'ck',checkbox:true,width:30},
    {field:'id',title:'订单ID',width:100,align:'center'},
    {field:'title',title:'名称',width:320,align:'left',search: true, nowsearch: true, searchtype: 'input',formatter:function(value,row,index){
        return value+(['',' <i class="fa fa-link" style="color:red" title="并房主订单"></i>',' <span style="color:red"><i class="fa fa-magnet" title="并房至"></i>['+(row.unToname || '')+']</span>'][row.unitype || 0] || '');
    }},
];
Core.Easyui.init($("#datalist"), {
    url: "{$_G['_mc_'] ?? ''}/ajax",
    idField: "id",
    fitColumns: false,
    singleSelect : true,
    columns: [Core.Easyui.FieldColumn],
    frozenColumns: [Core.Easyui.FrozenColumn],
    pageSize: 50,
    onDblClickRow: function (index,row){
        Core.Sys.Action('pop',row);
    },
},$(".search_form"));

Core.Sys.Action = function(Tkey,row){
    switch(Tkey){
        case 'migrate':
            var row = $('#datalist').datagrid('getSelected');
            if (row.payment != 0) {Core.Dialog.msg('已结账订单无法并房！');return;}
            Core.Dialog.open({'title': '订单并房,ID'+row.id+',包厢：'+row.title,'width': '550px','height': '320px','url': "{$_G['_mc_'] ?? ''}/migrate/id/"+row.id});
        break;
        case 'checkout':
            var row = $('#datalist').datagrid('getSelected');
            if (!row || row.payment != 0) {Core.Dialog.msg('订单已结账，不允许该操作');return;}
            Core.Dialog.confirm({'title':'订单结账','content':'该订单确定结账吗？','ok':function(cbk){
				$.get("{$_G['_mc_'] ?? ''}/checkout/id/"+row.id+"?r="+Math.random(),function(data){
					$("#datalist").datagrid('reload');cbk();
				});
			}})
        break;case 'info':
            var row = $('#datalist').datagrid('getSelected');if (!row){ Core.Dialog.msg('请选择需要编辑的数据！'); return;}
            Core.Sys.Action('pop',row);
        break;case 'delete':
            var row = $('#datalist').datagrid('getSelected');
            if (!row){Core.Dialog.msg('请选择需要删除的数据！');return;}
		    Core.Dialog.confirm({'title':'删除数据','content':'确认要删除该数据吗？','ok':function(cbk){
				$.get("{$_G['_mc_'] ?? ''}/delete/id/"+row.id+"?r="+Math.random(),function(data){
					$("#datalist").datagrid('reload');cbk();
				});
			}})
        break;case 'pop':
            if (!row) return;
            window.location.href = "/{$_G['_m_'] ?? ''}.info/index/id/"+row.id
        break;
    }
    return;
}
/**搜索 */
var Table_Filters = Core.Search.searchArray();
var filterType = Core.Search.typeList();
//var rsourceUrl = "/index/ajax/index"; //搜索字段基础数据
//var regionUrl = "/index/ajax/district/level/"; //城市搜索字段
Core.Search.initFilter("{$_G['_mc_'] ?? ''}/column",null);

$(document).ready(function(){
    $('.tools-bar').find('a[data-key]').on('click',function(){
        var Tkey = $(this).attr('data-key');
        if (!Core.rule('key',Tkey)) return false;
        Core.Sys.Action(Tkey);
    });
});
</script>
{include file="/public/footer" /}